package com.liang.localdatetime;

import java.time.DayOfWeek;
import java.time.LocalDateTime;

public class LocalDateTimeDemo {
    public static void main(String[] args) {
        LocalDateTime now = LocalDateTime.now();

        //获取年月日时分秒
        int year = now.getYear();
        System.out.print(year + "年“”“");

        int monthValue = now.getMonthValue();
        System.out.print(monthValue+"月");

        int dayOfMonth = now.getDayOfMonth();
        System.out.print(dayOfMonth+"日");

        int hour = now.getHour();
        System.out.print(hour+"时");

        int minute = now.getMinute();
        System.out.print(minute+"分");

        int second = now.getSecond();
        System.out.println(second+"秒");

        int dayOfYear = now.getDayOfYear();
        System.out.println("这是一年中的第"+dayOfYear+"天");

        DayOfWeek dayOfWeek = now.getDayOfWeek();
        String week = method(dayOfWeek);
        
        System.out.println(week);



    }

    private static String method(DayOfWeek dayOfWeek) {
        switch (dayOfWeek){
            case MONDAY:
                return "星期一";
            case THURSDAY:
                return "星期二";
            case WEDNESDAY:
                return "星期三";
            case TUESDAY:
                return "星期四";
            case FRIDAY:
                return "星期五";
            case SATURDAY:
                return "星期六";
            case SUNDAY:
                return "星期日";
            default:
                return "0";
        }
    }
}